﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Adams.Public.Api.Web.Controllers
{
    [EnsureHttps]
    public class DailyPrayersController : Controller
    {
        public ActionResult PageLoad(Adams.Public.DataTransfer.Web.DailPrayers.Index.PageLoadInput input)
        {
            int m = DateTime.Now.Month;

            if (string.IsNullOrEmpty(input.Location))
            {
                input.Location = "0";
            }

            bool isHijri = Adams.Shared.CalendarHelper.IsMonthHijri(input.Month);

            if (!string.IsNullOrEmpty(input.Month))
            {
                if (isHijri)
                {
                    m = Adams.Shared.CalendarHelper.GetHijriMonthID(input.Month);
                }
                else
                {
                    m = Adams.Shared.CalendarHelper.GetMonthID(input.Month);
                }
            }

            var model = DataAccess.Web.DailyPrayers.Index.PageLoad(input.Location, m, isHijri);
            return new JsonXmlResult(model);
        }
    }
}
